package test.typehandler;

import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

@MappedJdbcTypes(JdbcType.VARCHAR)
@MappedTypes(String.class)
public class StringTypeHandler extends BaseTypeHandler<String> {

    @Override
    public void setNonNullParameter(PreparedStatement ps, int i, String str, JdbcType jdbcType) throws SQLException {
        ps.setString(i, str + "typehandlerStr");
    }

    @Override
    public String getNullableResult(ResultSet res, String s) throws SQLException {
        return res.getString(s);
    }

    @Override
    public String getNullableResult(ResultSet res, int i) throws SQLException {
        return res.getString(i);
    }

    @Override
    public String getNullableResult(CallableStatement cal, int i) throws SQLException {
        return cal.getString(i);
    }
}
